package com.ljc.cjgl.entitiy;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import org.springframework.data.annotation.CreatedBy;

@Entity
public class TestRegister {
	private Integer id;
	private Stu student;
	private TbTest test;
	private String userName;
	private String pwd;
	private String projectUrl;
	private String sourceUrl;
	private Integer grade;
	private Boolean isShow=false;
	
	public TestRegister(Integer id) {
		super();
		this.id = id;
	}

	public TestRegister() {
		super();
	}
	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	@ManyToOne
	@CreatedBy
	public Stu getStudent() {
		return student;
	}

	public void setStudent(Stu student) {
		this.student = student;
	}
	
	@ManyToOne
	@CreatedBy
	public TbTest getTest() {
		return test;
	}

	public void setTest(TbTest test) {
		this.test = test;
	}
	
	@Column(length=20)
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	@Column(length=10)
	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
	
	@Column(length=100)
	public String getProjectUrl() {
		return projectUrl;
	}

	public void setProjectUrl(String projectUrl) {
		this.projectUrl = projectUrl;
	}

	public Integer getGrade() {
		return grade;
	}

	public void setGrade(Integer grade) {
		this.grade = grade;
	}
	
	public Boolean getIsShow() {
		return isShow;
	}

	public void setIsShow(Boolean isShow) {
		this.isShow = isShow;
	}

	@Transient
	public String getTestName() {
		return test==null?null:test.getName();
	}
	
	@Transient
	public Date getTestDate() {
		return test==null?null:test.getTestDate();
	}
	
	@Transient
	public String getStudentName() {
		return student==null?null:student.getName();
	}
	
	@Transient
	public String getStudentNum() {
		return student==null?null:student.getStuNum();
	}
	
	@Transient
	public String getClassName() {
		return student==null||student.getTbClass()==null?"":student.getTbClass().getName();
	}

	public String getSourceUrl() {
		return sourceUrl;
	}

	public void setSourceUrl(String sourceUrl) {
		this.sourceUrl = sourceUrl;
	}
	
	
}
